import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '告警名称',
    dataIndex: 'name',
  },
  {
    title: '监控项',
    dataIndex: 'alarmType',
  },
  {
    title: '告警渠道',
    dataIndex: 'messageWay',
  },
  {
    title: '是否启用',
    dataIndex: 'enable',
    slots: { customRender: 'executeCount' },
  },
  {
    title: '描述',
    dataIndex: 'desc',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'name',
    label: '名称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'messageWay',
    label: '告警渠道',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: '微信', value: 'WECHAT_ROBOT' },
        { label: '钉钉', value: 'DING_ROBOT' },
        { label: '飞书', value: 'FEI_SHU_ROBOT' },
      ],
    },
  },
  {
    field: 'enable',
    label: '是否启用',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: '是', value: 'true' },
        { label: '否', value: 'false' },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '告警名称',
    field: 'name',
    component: 'Input',
    required: true,
  },
  {
    label: '告警描述',
    field: 'desc',
    component: 'Input',
  },
  {
    label: '监控项',
    field: 'alarmType',
    component: 'Select',
    componentProps: {
      options: [
        { label: '主机CPU告警', value: 'CPU_LOAD_ALARM' },
        { label: '主机内存告警', value: 'MEMORY_LOAD_ALARM' },
        { label: '集群节点状态告警', value: 'CLUSTER_NODE' },
        { label: '规则引擎故障告警', value: 'RULE_ENGINE_ERROR' },
        { label: '非法连接告警', value: 'ILLEGAL_CONNECTION' },
        { label: '集群状态告警', value: 'CLUSTER_STATE_UPDATE' },
      ],
    },
    required: true,
  },
  {
    label: '告警渠道',
    field: 'messageWay',
    component: 'Select',
    componentProps: {
      options: [
        { label: '微信', value: 'WECHAT_ROBOT' },
        { label: '钉钉', value: 'DING_ROBOT' },
        { label: '飞书', value: 'FEI_SHU_ROBOT' },
      ],
    },
    required: true,
  },
  {
    label: '报警接收人(微信ID)',
    field: 'desc',
    component: 'Input',
  },
  {
    label: 'Hook地址',
    field: 'hook',
    component: 'Input',
    required: true,
  },
  {
    label: '是否启用',
    field: 'enable',
    component: 'JSwitch',
    componentProps: {
      options: ['1', '0'],
    },
  },
];
